//
//  StatusesCell.swift
//  weibo1
//
//  Created by Apple on 15/12/1.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit
import SnapKit

let OffsetCell :CGFloat = 12
let SizeWidth :CGFloat = 35
class StatusesCell: UITableViewCell {
    var status :statuses? {
        
        didSet{
            //转发微博的数据
            print(status?.retweeted_status?.text)
            headview.status = status
            //给转发微博赋值
        }
        
    }
    
    
    //重写初始化方法
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
        //取消cell能被点击的状态
        selectionStyle = .None
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //headview布局
    private func setupUI() {
        
        contentView.addSubview(headview)
        contentView.addSubview(footview)
        contentView.addSubview(turnView)
        headview.snp_makeConstraints { (make) -> Void in
            make.top.left.right.equalTo(contentView)
        }
        //底部视图的约束
        footview.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(turnView.snp_bottom)
            make.left.right.equalTo(contentView)
            make.height.equalTo(40)
        }
        //转发微博
        turnView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(headview.snp_bottom).offset(OffsetCell)
            make.left.right.equalTo(contentView)
        }
        
        
        
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.left.right.equalTo(self)
            make.bottom.equalTo(footview.snp_bottom)
        }
    }
    
    //添加头部view
    private lazy var headview : HeadView = HeadView()
    
    //添加底部view
    private lazy var footview : FootView = FootView()
    
    //添加中间转发微博
    private lazy var turnView : TurnView = TurnView()
}
